#include "stdafx.h"
#include "collada.h"

#ifdef _DEBUG
#define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ )
#define new DEBUG_NEW
#endif

using namespace Collada;

IMPLEMENT_RTTI( Collada::Scene, Collada::Element )
IMPLEMENT_ELEMENT( Collada::Scene )

Scene::Scene( const std::string& id, const std::string& name )
:	Element( id, name )
,	_pRootScene( NULL )
{
	CHILD_ELEMENT_BEGIN()
		CHILD_ELEMENT( "instance_physics_scene",	Collada::Empty )
		CHILD_ELEMENT( "instance_visual_scene",		Collada::Empty )
		CHILD_ELEMENT( "instance_kinematics_scene",	Collada::Empty )
		CHILD_ELEMENT( "extra",						Collada::Empty )
	CHILD_ELEMENT_END()
}

Scene::~Scene()
{
}

void Scene::AllChildElementsLoaded( Element* pParent )
{
	( ( Data* )pParent )->AddScene( this );
}

void Scene::Initialize( Element* pParent, const void* desc )
{
	TiXmlElement* pElem = ( TiXmlElement* )desc;
	TiXmlElement* pChild = NULL;

	pChild = pElem->FirstChildElement( "instance_visual_scene" );
	if( pChild != NULL )
	{
		const char* url = pChild->Attribute( "url" );
		ID urlId = Fundamental::JenkinsPHF( &url[1] );
		_pRootScene = ( ( Data* )pParent )->GetVisualScene( urlId );
		
	}
}

bool Scene::IsValid( const void* desc )
{
	return true;
}